<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<html>
	 <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
        <meta name="format-detection" content="telephone=no">
        <meta charset="UTF-8">

        <meta name="description" content="Violate Responsive Admin Template">
        <meta name="keywords" content="Super Admin, Admin, Template, Bootstrap">

        <title>萌淘淘商城后台</title>
   		<link href="<%=path %>/assets2/css/bootstrap.min.css" rel="stylesheet">
		<link href="<%=path %>/assets2/css/styles.css" rel="stylesheet">
		
		<link href="<%=path %>/assets2/js/sweetalert/sweetalert.css" rel="stylesheet">
   		<script src="<%=path %>/assets2/js/sweetalert/sweetalert-dev.js"></script>
   		<script src="<%=path %>/assets2/js/sweetalert/sweetalert.min.js"></script>   
   		<script src="<%=path %>/assets2/js/jquery-1.11.1.min.js"></script>
		<script src="<%=path %>/assets2/js/bootstrap.js"></script>
		<script src="<%=path %>/assets2/js/openHtml.js"></script> 
		<link href="<%=basePath%>/assets/layer/theme/default/layer.css" rel="stylesheet" type="text/css">
		<script src="<%=basePath%>/assets/layer/layer.js"></script>
		<script src="<%=path%>/assets2/js/moment-with-locales.min.js"></script>
		
    </head>
    <body>
	<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
		<div class="container-fluid">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#sidebar-collapse">
					<span class="sr-only">菜单</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="<%=path %>/index"><span>萌淘淘商城</span></a>
				<ul class="user-menu">
					<li class="pull-left">
						<a href="<%=path %>/index"><span class="glyphicon glyphicon-user">${user.userName }&nbsp;&nbsp;</span></a>
					</li>
					<li class="pull-left" onclick="updPassWord()">
						<a href="#"><span class="glyphicon glyphicon-edit">密码修改&nbsp;&nbsp;</span></a>
					</li>
					<li class="pull-right">
						<a href="<%=path %>/j_spring_security_logout"><span class="glyphicon glyphicon-log-out"></span>退出登录</a>
					</li>
				</ul>
			</div>
		</div><!-- /.container-fluid -->
	</nav>
		
	<div id="sidebar-collapse" class="col-sm-3 col-lg-2 sidebar">
		
		<ul class="nav menu">
			<li class="active"><a href="<%=path %>/index" ><span class="glyphicon glyphicon-dashboard"></span> 首页</a></li>
			<li><a href="javascript:;" onclick="openBodyHtml('<%=path %>/jsp/bbsManager/systemMessage.jsp')"><span class="glyphicon glyphicon-th"></span> 系统消息</a></li>
<%-- 			<li><a href="javascript:;" onclick="openBodyHtml('<%=path %>/jsp/bbsManager/usersManager.jsp')"><span class="glyphicon glyphicon-th"></span> 用户管理</a></li> --%>
			<li><a href="javascript:;" onclick="openBodyHtml('<%=path %>/jsp/bbsManager/postList.jsp')"><span class="glyphicon glyphicon-th"></span> 论坛信息管理</a></li>
		</ul>
	</div>
	<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">			
		
	</div>	
<script>
		$('.menu li').on('click',function(){
			$('li').removeClass('active');
			$(this).addClass('active');
		})
		context_path='<%=path%>';
		
		//修改密码
		function updPassWord(){
			var html = '<br><div class="col-md-12">'
				+'<label class="control-label col-md-4">原密码</label>'
				+'<div class="col-md-8"><input type="text" class="form-control" id="passwordOld">'
				+'</div></div>'
			    + '<br><br><br><div class="col-md-12">'
				+'<label class="control-label col-md-4">新密码</label>'
				+'<div class="col-md-8"><input type="text" class="form-control" id="passwordNew">'
				+'</div></div>';
				//页面层
				layer.open({
				  type: 1,
				  title:'密码修改',
				  shadeClose:true,
				  content: html,
				  btn: ['添加', '取消'],
				  btn1: function(){
					  var passwordOld = $("#passwordOld").val();
					  var passwordNew = $("#passwordNew").val();
						if(passwordOld==null||passwordOld==''){
							//tips层
							layer.tips('原密码不能为空~', '#passwordOld');
							return false;
						}else if(passwordNew==null||passwordNew==''){
							//tips层
							layer.tips('新密码不能为空~', '#passwordNew');
							return false;
						}else{
						$.ajax({
							 type:"POST",
							 data: {"passwordNew":passwordNew,"passwordOld":passwordOld},
					         url: "<%=path %>/common/updatePassWord",
					         success: function(data,status,xhr){
					        	 if(data==1){
					        		 layer.closeAll();
					        		 swal({ 
							   			  title: "成功", 
							   			  text: "修改密码成功~", 
							   			  type: "success",
							   			},function(){
							   				window.location.href='<%=path %>/j_spring_security_logout';
							   			});
					        	 }else if(data==-1){
					        		 layer.tips('原密码错误~', '#passwordOld');
					        	 }else{
					        		 layer.closeAll();
					        		 swal({ 
							   			  title: "失败", 
							   			  text: "修改密码失败~", 
							   			  type: "error",
							   			}); 
					        	 }
					         },error:function (){
					        	 layer.closeAll();
					        	 swal({ 
						   			  title: "编辑失败", 
						   			  text: "网络错误,请稍后尝试~", 
						   			  type: "warning",
						   			});
					         }
						});
					  }
				  }
				});
		};
		
</script>	
	
	</body>
</html>